<?php

class LoginManager extends BaseManager implements iManager {
	
	public function query(){
		// Get login ID
		
		$query = "SELECT MAX(login_id) as `loginId` FROM `login_tbl` WHERE employee_id =" . $this->obj->getEmployeeId();
				
		$this->db->query($query);
		
		$this->db->execute();
		
		$result = $this->db->getResultAssoc();
		
		return $result;
		
		
	}
	
	public function add(){
		
		$data['employee_id'] = $this->obj->getEmployeeId();
		$logDate = date('Y-m-d H:i:s',strtotime($this->obj->getLoginDetails()->getLoginDateTime()));
		$data['login_datetime'] = $logDate;
		
		$this->db->insert('login_tbl', $data);
		
		$this->db->execute();
	}
	
	public function update(){
		
		//get maxID
		$loginId = $this->query();
		$where['login_id'] = $loginId['loginId'];
		
		$data['employee_id'] = $this->obj->getEmployeeId();
		$data['logout_datetime'] = date('Y-m-d H:i:s');
		
		$this->db->update('login_tbl', $data, $where);
		
		$this->db->execute();
		
	}
	
	public function delete(){
		
	}
	
	
}